<template>
  <div class="ec-app-container">
    <!-- 查询条件 -->
    <div class="filter-container">
      <el-form label-width="90px">
        <el-row :gutter="10">
          <el-col :span="6">
            <el-form-item label="姓名：">
              <el-input v-model="listQuery.name" placeholder="视频标题" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="手机号：">
              <el-input v-model="listQuery.phone" placeholder="手机号" />
            </el-form-item>
          </el-col>
          <!--<el-col :span="6">-->
          <!--<el-form-item label="职位：" >-->
          <!--<el-input v-model="listQuery.position" placeholder="职位"/>-->
          <!--</el-form-item>-->
          <!--</el-col>-->
          <el-col :span="6" class="text-center">
            <el-button
              type="primary"
              class="border-4C7FD7 color-4C7FD7"
              icon="el-icon-search"
              @click="searchList"
            >查询</el-button
            >
            <el-button
              class="border-4C7FD7 color-4C7FD7"
              @click="resetSearch"
            >重置</el-button
            >
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!-- table -->
    <div>
      <div class="mt-30">
        <!-- <el-button class="filter-item" type="primary" @click="showDialog('新增置业顾问')" >新增</el-button>  -->
        <el-button
          class="filter-item"
          type="primary"
          @click="toAdd"
        >新增</el-button
        >
        <el-button
          class="filter-item"
          type="primary"
          @click="toAdd"
        >回赠名片</el-button
        >
        <el-button
          class="filter-item"
          type="primary"
          @click="toAdd"
        >意向客户</el-button
        >
      </div>
      <div class="mt-20">
        <el-table
          v-loading="listLoading"
          :data="list"
          border
          fit
          highlight-current-row
          style="width: 100%;"
          @selection-change="handleSelectionChange"
        >
          <el-table-column type="selection" width="55" />
          <el-table-column label="操作" align="center" width="150">
            <template slot-scope="scope">
              <el-button
                v-if="scope.row.status == 1"
                type="text"
                size="mini"
                @click="releaseStatus(scope.row, 0, '发布')"
              >发布</el-button
              >
              <el-button
                v-else
                type="text"
                size="mini"
                @click="releaseStatus(scope.row, 1, '撤回')"
              >撤回</el-button
              >
              <el-button
                type="text"
                size="mini"
                @click="updateDialog(scope.row, '新增置业顾问')"
              >编辑</el-button
              >
              <el-button
                type="text"
                size="mini"
                @click="deleteDate(scope.row.id, '删除置业顾问')"
              >删除</el-button
              >
            </template>
          </el-table-column>
          <el-table-column label="姓名" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.name }}</span>
            </template>
          </el-table-column>
          <el-table-column label="手机号" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.phone }}</span>
            </template>
          </el-table-column>
          <el-table-column label="微信号" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.weixinAccount }}</span>
            </template>
          </el-table-column>
          <el-table-column label="职位" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.position }}</span>
            </template>
          </el-table-column>
          <!--<el-table-column label="浏览人数" align="center">-->
          <!--<template slot-scope="scope">-->
          <!--<span>{{ scope.row.teamName }}</span>-->
          <!--</template>-->
          <!--</el-table-column>-->
          <!--<el-table-column label="点赞数" align="center">-->
          <!--<template slot-scope="scope">-->
          <!--<span>{{ scope.row.responsibleBuilding }}</span>-->
          <!--</template>-->
          <!--</el-table-column>-->
          <el-table-column label="状态" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.status }}</span>
            </template>
          </el-table-column>
          <el-table-column label="更新时间" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.updateTime.substr(0, 10) }}</span>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <!--<pagination v-show="total>0" :total="total" :page.sync="listQuery.pageNum" :limit.sync="listQuery.pageSize" @pagination="searchList" />-->
    </div>
    <!-- 新增修改 -->
    <el-dialog :visible.sync="dialogFormVisible" :title="message" width="550px">
      <el-form
        ref="objectForm"
        :model="object"
        :rules="objectRules"
        label-width="130px"
      >
        <el-row>
          <el-form-item label="姓名：" prop="name">
            <el-input v-model="object.name" />
          </el-form-item>
          <!--<el-form-item label="账号：" prop="roleName">-->
          <!--<el-input v-model="object.videoTitle"/>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="密码：" prop="roleName">-->
          <!--<el-input v-model="object.videoDesc"/>-->
          <!--</el-form-item>-->
          <!--<el-form-item label="确认密码：" prop="roleName">-->
          <!--<el-input v-model="object.videoDesc"/>-->
          <!--</el-form-item>-->
          <el-form-item label="手机号：" prop="phone">
            <el-input v-model="object.phone" />
          </el-form-item>
          <el-form-item label="微信号：" prop="wechatID">
            <el-input v-model="object.wechatID" />
          </el-form-item>
          <el-form-item label="职位：" prop="position">
            <el-input v-model="object.position" />
          </el-form-item>
          <el-form-item label="团队名称：" prop="TeamName">
            <el-input v-model="object.TeamName" />
          </el-form-item>
          <el-form-item label="所属项目公司：" prop="projectCompany">
            <el-input v-model="object.projectCompany" />
          </el-form-item>
          <el-form-item label="关联楼盘：" prop="responsibleBuilding">
            <el-input v-model="object.responsibleBuilding" />
          </el-form-item>
          <el-form-item label="账户状态：" prop="status">
            <el-radio-group v-model="object.status">
              <el-radio :label="0">正常</el-radio>
              <el-radio :label="1">禁用</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="onCancel">取 消</el-button>
        <el-button
          :loading="btnLoading"
          type="primary"
          @click="onSubmit(message)"
        >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Pagination from '@/components/Pagination' // Secondary package based on el-pagination、
import { getBusinessCardList } from '@/api/adviser.js'
import mixin from './rules/adviser'
export default {
  name: 'Adviser',
  components: {
    Pagination
  },
  mixins: [mixin],
  data() {
    return {
      message: '',
      listLoading: false,
      total: 0,
      list: [],
      listQuery: {
        // memberType: '3', // 会员类型，1-瑞信 2-电商，3-房云
        name: '',
        phone: '',
        position: '',
        pageSize: 10,
        pageNum: 1,
        weixinAccount: ''
      },
      object: {
        // backgroundImg: "",
        // browseNum: 0,
        company: '',
        // faceImg: "",
        id: 0,
        // likeNum: 0,
        // memberId: "",
        name: '',
        phone: '',
        // photo: "",
        position: '',
        // recommendRoom: "",
        // signature: "",
        status: '',
        // title: "",
        type: 0,
        // video: "",
        weixinAccount: ''
        // // =====
        // 'name': '',
        // 'phone': '',
        // 'wechatID': '',
        // 'position': '',
        // 'TeamName': '',
        // 'projectCompany': '',
        // 'responsibleBuilding': '',
        // 'status': 1,
        // 'level2': '',
        // 'level1': '',
        // 'level': 'fy_propertyConsultant'
      }
    }
  },
  created() {
    // 初始化
    this.searchList()
  },
  methods: {
    toAdd() {
      window.console.log('111')
      this.$router.push('addCallcard')
    },
    getList(listQuery) {
      this.listLoading = true
      getBusinessCardList(listQuery).then((res) => {
        this.list = res.data.list
        this.total = res.data.total
        this.listLoading = false
      })
    },
    searchList() {
      const listQuery = this._.cloneDeep(this.listQuery)
      this.getList(listQuery)
    }
  }
}
</script>

<style scoped></style>
